package com.itheima.tcpcomcn;

import java.io.*;
import java.net.Socket;

public class ClientDemo {
    public static void main(String[] args) throws IOException {
        //创建网络对象
        Socket socket = new Socket("127.0.0.1",10080);
        //创建本地流对象，从本地读取数据
        BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream("Day15\\dir\\dao.txt"));
        //创建网络流对象
        OutputStream outputStream = socket.getOutputStream();
       // BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream);
        //将本地流文件写到网络流中
        int b;
        while((b =bufferedInputStream.read())!=-1){
            outputStream.write(b);
        }
        socket.shutdownOutput();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String d ;
        while ((d=bufferedReader.readLine())!=null){
            System.out.println(d);
        }
        bufferedInputStream.close();
        socket.close();
    }
}
